import { createRouter, createWebHistory, } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/zhy-views/HomeView.vue'),
      children: [
        {
          path: "/home/toexercise",
          name: "toexercise",
          component: () => import("../views/bjk-views/ToExercise.vue")
        },
        {
          path: '/home/match',
          component: () => import('../views/Wm/Match.vue')
        },
        {
          path: "/home/index",
          name: "homepage",
          component: () => import("../component/yyp-component/HomePage.vue")
        },
        {
          path: "/home/sports",
          name: "sports",
          component: () => import("../views/zhy-views/Sports/SportsView.vue"),
          children: [
            {
              path: "/home/sports/venue",
              name: "venue",
              component: () => import("../views/zhy-views/Sports/Venue.vue")
            },
            {
              path: "/home/sports/bank",
              name: "bank",
              component: () => import("../views/zhy-views/Sports/Bank.vue")
            },
            {
              path: "/home/sports/fight",
              name: "fight",
              component: () => import("../views/zhy-views/Sports/Fight.vue")
            },
            {
              path: "/home/sports/train",
              name: "train",
              component: () => import("../views/zhy-views/Sports/Train.vue")
            },
            {
              path: "/home/sports/friends",
              name: "friends",
              component: () => import("../views/zhy-views/Sports/Friends.vue")
            },

          ],
          redirect: "/home/sports/venue"
        },
        {
          path: "/home/my",
          name: "my",
          component: () => import('../views/liyansenmy/my.vue')
        }

      ],
      redirect: "/home/index",
    },
    {
      path: "/funroute",
      name: "funroute",
      component: () => import("../views/zhy-views/FunRouteView.vue")
    },
    {
      path: "/routeplan",
      name: "routeplan",
      component: () => import("../views/zhy-views/RoutePlanView.vue")
    },
    {
      path: "/mileage",
      name: "mileage",
      component: () => import("../views/bjk-views/MileAge.vue")
    },
    {
      path: "/addfriend",
      name: "addfriend",
      component: () => import("../views/zhy-views/Sports/AddFriends.vue")
    }
  ]
})


// router.beforeEach((to,from,next)=>{
//   const token = localStorage.getItem("token")
//   const allowedPathsWithoutToken = ["/login", "/handset", "/goto"];
//   if(token || allowedPathsWithoutToken.includes(to.path)){
//     next()
//   }else {
//     next("/login")
//   }
// })

export default router
